function doit()
{
	//pageNum= document.form2.pageNum.value;
	pageNum=document.getElementsByName("pageNum");
	pageNum=pageNum[0].value;
	//alert(pageNum);
	document.form1.action="find_notbaojia.jsp?pageNum=" + pageNum;
	//alert(document.form1.action);
	document.form1.submit();
}
function schedule(item)
{
	//alert("����ִ������ת��ϸ����");
	//alert(item);
	var p=item.parentNode;
	p=p.parentNode;
	p=p.childNodes[0];
	p=p.firstChild;
	//alert(p.data);
	window.location.href="similarcost.jsp?transnum="+p.data;
}
function forward_backward(page_num)
{
	document.getElementsByName("pageNum")[0].value=page_num;
	//alert(document.getElementsByName("pageNum")[0].value);
	document.form1.action="find_notbaojia.jsp";
	document.form1.submit();
}
function forward_backward_maopi(page_num)
{
	//alert(page_num);
	document.getElementsByName("pageNum")[0].value=page_num;
	document.form1.action= "modify_diandu.jsp?pageNum=" + eval(page_num);
	document.form1.submit();
}
function doit_a(site)
{
	//pageNum= document.form2.pageNum.value;
	//alert(site);
	pageNum=document.getElementsByName("pageNum");
	//alert(pageNum);
	pageNum=pageNum[0].value;
	//alert(pageNum);
	//alert(document.form1.action);
	document.form1.action=site+".jsp?pageNum=" + pageNum;
	//alert(document.form1.action);
	document.form1.submit();
}
function forward_backward_a(site,page_num)
{
	//alert(page_num+"&&"+site);
	document.getElementsByName("pageNum")[0].value=page_num;
	//alert(document.getElementsByName("pageNum")[0].value);
	document.form1.action= site+".jsp?pageNum=" + eval(page_num);
	//alert(document.form1.action);
	document.form1.submit();
}
function creatediandu()
{
	var plate=document.getElementById("plate");
	var danjia=document.getElementById("danjia");
	var date=document.getElementById("modifydate");
	if(!isFloat(danjia.value))
		{danjia.focus(); alert("����ĵ��۲���ʵ������������");return false;}
	window.location.href="../maopidoing?action=create&plate="+plate.value+"&danjia="+danjia.value+"&modifydate="+date.value;
}
function deleteBy(item)
{
	var tditem=item.parentNode;
	var tritem=tditem.parentNode;
	var plate=tritem.childNodes[0].firstChild.value;
	//alert(plate);
	if(window.confirm("�Ƿ������Ҫɾ��?"))
	window.location.href="modify_huilv?action=delete&huilv_name="+plate;
	else
        return false;

}
function updateBy(item)
{
	var tditem=item.parentNode;
	var tritem=tditem.parentNode;
	var plate=tritem.childNodes[0].firstChild.value;
	///alert(plate);
	var danjia=tritem.childNodes[1].firstChild.value;
	//alert(danjia);
	var modify=tritem.childNodes[2].firstChild.value;
	if(checkChange())
	window.location.href="modify_huilv?action=update&huilv_name="+plate+"&rate="+danjia+"&modifydate="+modify;
	else
	return false;
}
function createBy()
{
	var plate=document.getElementById("huilv_name");
	var danjia=document.getElementById("rate");
	var date=document.getElementById("modifydate");
	if(!isFloat(danjia.value))
		{danjia.focus(); alert("����ĵ��۲���ʵ������������");return false;}
	window.location.href="modify_huilv?action=create&huilv_name="+plate.value+"&rate="+danjia.value+"&modifydate="+date.value;
}
function deletemaopi(item)
{
	var tditem=item.parentNode;
	var tritem=tditem.parentNode;
	var plate=tritem.childNodes[0].firstChild.value;
	//alert(plate);
	if(window.confirm("�Ƿ������Ҫɾ��?"))
	window.location.href="../maopidoing?action=delete&plate="+plate;
	else
        return false;

}
function updatemaopi(item)
{
	var tditem=item.parentNode;
	var tritem=tditem.parentNode;
	var plate=tritem.childNodes[0].firstChild.value;
	///alert(plate);
	var danjia=tritem.childNodes[1].firstChild.value;
	//alert(danjia);
	var modify=tritem.childNodes[2].firstChild.value;
	if(checkChange())
	window.location.href="../maopidoing?action=update&plate="+plate+"&danjia="+danjia+"&modify="+modify;
	else
	return false;
}

/**
* Ĭ�ϱ���5λС��
*/
function costtrim(item)
{
	num=new String(item);
	//alert("num"+num);
	var temp=num.split(".");
	if(temp.length!=2)
	{//alert("�Բ�����ʵ��");
		return item;
	}
	var zheng=myParseFloat(temp[0]);
	var xiao=myParseFloat(0+"."+temp[1]);
        var geshu=5;
	var xiao_length=temp[1].length;
	if(xiao_length<5)
	geshu=xiao_length;
	var xishu=1;
	var temp=0;
	for(var i=0;i<geshu;i++)
	{
		xiao=xiao*10;
		temp+=parseInt(xiao);
		xiao=xiao-parseInt(xiao);
		xishu*=10;
		temp*=10;
	}
	temp=temp/10;
	if(xiao>0)
	{
		xiao=parseInt(xiao*10);
//		alert("xiao"+xiao);
		if(xiao>4)
			temp+=1;
	}
		zheng=zheng.add(temp/xishu);
	return zheng;

}


var mydensity;
//��Ӧ�ӹ��ӹ��Ѽ�������Ժ�,
function shurujiagong(item)
{
    var tab=document.getElementById("table3");
    if(tab.style.display=="none"){
	tab.style.display="block";
	document.all.xianshi.firstChild.data="����";
	}
      else{
      	tab.style.display="none";
	document.all.xianshi.firstChild.data="��ʾ";

	var tab03=document.getElementById("table3");

	var length=tab03.rows.length;
	//ֱ��ȡ���һ�е����һ�����Ϊֹ�ĳɱ�.
	var lasttd=tab03.rows[length-1].lastChild.firstChild;

	var jia=$("mtrlprocsprice");

	jia.value=costtrim(lasttd.value);

	}
}
function changek(item)
{
	var hid=document.getElementById("kaimohid");
	hid.value=item.value;
}

//���ӹ��ѷ���仯��ʱ�����¼��������еĳɱ���
//��Ʒ���=�������+��װ��+��̷�*�ӹ���;���ϷѾͲ���Ҫ����.���ڼӹ���������.
function mycalc()
{
//	alert("recalc");
	var base=document.getElementById("basecost");
	var other=document.getElementById("otherfee").value;
	var pack=document.getElementById("packfee").value;
	var congci=document.getElementById("congcifee").value;
	var jiagong=document.getElementById("mtrlprocsprice").value;
	//var cailiao=document.getElementById("grossprice").value;

	var temp=myParseFloat(other)+myParseFloat(pack)+myParseFloat(congci)+myParseFloat(jiagong)
	base.value=costtrim(temp);
}
//������Ϸ���.=��������*���ϵ���*ë����
function maopits()
{
	var gross=document.getElementById("grossupdate");
	var price=document.getElementById("grossgprice");
	var weight=document.getElementById("grossweight");
	var cailiao=document.getElementById("grossprice");
	cailiao.value=costtrim(myParseFloat(gross.value)*myParseFloat(price.value)*myParseFloat(weight.value));
}
//���Ϸѷ���仯��ʱ��,��Ҫ�޸ļӹ���.
function changeCaiLiao()
{
	var table3=$("table3");
	var row_len=table3.rows.length;
	var cailiao=document.getElementById("grossprice");
	//�޸ĵ�һ�еļӹ��ѾͿ�����.
	//alert("row_len:"+row_len);
	if(row_len>1)
	{
		var tr_1=table3.rows[1];//��һ��.
		var pro_num=tr_1.childNodes[3].firstChild;// �ӹ�����.
		var pro_unit=tr_1.childNodes[8].firstChild;// �ӹ��۸�.
		var pro_per=tr_1.childNodes[7].firstChild;// �ӹ���Ʒ��.
		var pro_last=tr_1.childNodes[9].firstChild;// ��ĿǰΪֹ�ĳɱ�.

		pro_last.value=costtrim((myParseFloat(pro_unit.value)+myParseFloat(cailiao.value)/myParseFloat(pro_num.value))/myParseFloat(pro_per.value));
	}

}

//�ܶȱ仯����.
function changedensity()
{
	//alert(mydensity);
	var newdensity=document.getElementById("density").value;

	var gross=document.getElementById("grossweight").value;
	document.getElementById("grossweight").value=costtrim(myParseFloat(gross)/myParseFloat(mydensity)*myParseFloat(newdensity));
	var net=document.getElementById("netweight").value;
	document.getElementById("netweight").value=costtrim(myParseFloat(net)/myParseFloat(mydensity)*myParseFloat(newdensity));
	mydensity=newdensity;
}
//���ر仯,ǣ������װ�ѵı仯.
function changenet()
{
	var net=document.getElementById("netweight");
	var bz=document.getElementById("packfee");
	bz.value=costtrim(myParseFloat(net.value)*1.8/1000);
}
//��Ʒ��۸�仯��ʱ��.
function lastcalc()
{
	var base=document.getElementById("basecost");
	//var total=document.getElementById("totalupdate");
	document.getElementById("amount").value=costtrim(myParseFloat(base.value));//*(1+myParseFloat(total.value)));
}
//����Ѻ�˰��.
function proCalc()
{
	var amount=document.getElementById("amount");
	var sxr=document.getElementById("sanxiangrate");
	var sx_fee=document.getElementById("sanxiangfee");
	sx_fee.value=costtrim(myParseFloat(amount.value)*(myParseFloat(sxr.value)));
	var rate=document.getElementById("taxrate");
	var tax_fee=document.getElementById("taxfee");
	tax_fee.value=costtrim(myParseFloat(amount.value)*(myParseFloat(rate.value)));
}
function sxr()
{
	var amount=document.getElementById("amount");
	var sxr=document.getElementById("sanxiangrate");
	var sxr_fee=document.getElementById("sanxiangfee");
	sxr_fee.value=costtrim(myParseFloat(amount.value)*(myParseFloat(sxr.value)));
}
function sxrCalc()
{
	var amount=document.getElementById("amount");
	var sx_fee=document.getElementById("sanxiangfee");
	var tax_fee=document.getElementById("taxfee");
	var mtrlprocs=document.getElementById("mtrlprocs");
	//alert(amount);
	mtrlprocs.value=costtrim(myParseFloat(amount.value)+(myParseFloat(sx_fee.value))+(myParseFloat(tax_fee.value)));
}

function rate()
{
	var amount=document.getElementById("amount");
	var tax=document.getElementById("taxrate");
	var tax_fee=document.getElementById("taxfee");
	tax_fee.value=costtrim(myParseFloat(amount.value)*(myParseFloat(tax.value)));
}
function rateCalc()
{
	var amount=document.getElementById("amount");
	var sx_fee=document.getElementById("sanxiangfee");
	var tax_fee=document.getElementById("taxfee");
	var mtrlprocs=document.getElementById("mtrlprocs");
	mtrlprocs.value=costtrim(myParseFloat(amount.value)+(myParseFloat(sx_fee.value))+(myParseFloat(tax_fee.value)));
}
var XianQieGe="���и�";
var SecondQie="��Ƭ2";
var FirstQie="��Ƭ1";
var Qie="��Ƭ";

//�����ܶȳ�ʼ����.
function myReset()
{
	window.location.href="modify_density.jsp?action=reset";
}
//���һ���ܶȺ��ƺŵĶ�Ӧ��ϵ.
function myAdd()
{
	var table=document.getElementById("table01");

	var len=table.rows.length;
	//alert(len);
	var input=document.createElement("input");
	var myrow=table.rows[len-1];
	var row_len=myrow.cells.length;


	var mycell_ssign=myrow.cells[row_len-2].firstChild;
	var mycell_density=myrow.cells[row_len-1].firstChild;

	var ssign=new String(mycell_ssign.getAttribute("name"));
	var density=new String(mycell_density.getAttribute("name"));
	var start=ssign.indexOf("_");
	var num=myParseFloat(ssign.substring(start+1));
	input.setAttribute("name",ssign.substring(0,start+1)+(num+1));


	if(row_len==4)
		{table.insertRow();myrow=table.rows[len];}
	$(myrow).className="input";
	var last_cell=myrow.insertCell();
	last_cell.appendChild(input);

	//
	input=document.createElement("<input type='text'>");
	//alert(density);
	start=density.indexOf("_");
	//alert(start);
	//alert("num_str:"+density.substring(start+1));
	num=myParseFloat(density.substring(start+1));
	input.setAttribute("name",density.substring(0,start+1)+(num+1));
	//alert(input.getAttribute("name"));
	last_cell=myrow.insertCell();
	last_cell.appendChild(input);
}
function change(num)
{
	//alert(num);
	if(!checkChange())
		return false;
	if(!checkMaoPiChange(num))
		return false;
	document.getElementsByName("num")[0].value=num;
	document.form1.submit();
}
function checkMaoPiChange(num)
{
	for(var i=1;i<=7;i++)
		{
		var tt=document.getElementsByName("yz_"+i+num)[0].value;
		//alert(tt);
		if(!isFloat(tt))
		{alert(tt+"����ʵ���밴��׼�������ܶ�");return false;}
		}
	return true;
}
function delete_m(num)
{
	//alert(num);
	if(!checkRemove())
		return false;
	document.getElementsByName("num")[0].value=num;
	document.getElementsByName("action1")[0].value="delete";
	document.form1.submit();
}
function createmaopi()
{
	document.getElementsByName("action1")[1].value="new";
	document.form3.submit();
}
function myReset()
{
	window.location.href="modify_density.jsp?action=reset";
}
function toggle(itemname)
{
	var objobject= document.getElementById(itemname);
	if (objobject.style.display== "block")
	  {
	    objobject.style.display= "none";
	  }
	 else
	   {
	     objobject.style.display= "block";
	   }
}
/*��ʱ�Ȳ�Ҫ���ȥ.*/
function tijiao()
{
	document.form1.action="manucost_doing.do";
	//document.form1.submit();
}

function density_c(item)
{
	//alert(item.value);
	if(isEmpty(item.value))
		return true;
	if(!reDensity.test(item.value))
		{alert("��������ܶ���ʽ����,�밴��'N33_N44'��ʽ�������롣����ɾ�����㼴�ɡ�");return false;}
	return true;
}
function qiepian_update(item)
{
	//alert(item.value);
	if(isEmpty(item.value))
		return true;
	if(!reQie.test(item.value))
		{alert("���������Ƭ��ʽ����,�밴��'33_44'����'60'��ʽ�������롣");item.focus();return false;}
	return true;
}
function highSsignAdd()
{

	var table=$("table01");

	var len=table.rows.length;
	//���һ��
	var myrow=table.rows[len-1];

	var mycell_ssign=myrow.cells[0].firstChild;

	var ssign=new String(mycell_ssign.getAttribute("name"));

	var start=ssign.lastIndexOf("_");
	var num=myParseFloat(ssign.substring(start+1))+1;

	var input=document.createElement("<input type='text' name='key_"+num+"'>");
	//alert("highssign:"+input.name);
	table.insertRow();
	myrow=table.rows[len];
      	$(myrow).className="input";

	var last_cell=myrow.insertCell();
	last_cell.appendChild(input);

}
function myQpAdd(table_id)
{
	//alert(table_id);
	var table=$(table_id);
	//alert(table.childNodes.length);
	var len=table.rows.length;
	var input=document.createElement("<input type='text'>");
	var myrow=table.rows[len-1];
	var row_len=myrow.cells.length;


	var mycell_ssign=myrow.cells[row_len-2].firstChild;
	var mycell_density=myrow.cells[row_len-1].firstChild;

	var ssign=new String(mycell_ssign.getAttribute("name"));
	var density=new String(mycell_density.getAttribute("name"));

	var start=ssign.lastIndexOf("_");
	var num=myParseFloat(ssign.substring(start+1));
	input.setAttribute("name",ssign.substring(0,start+1)+(num+1));

	//
	table.insertRow();
	myrow=table.rows[len];
      	$(myrow).className="input";

	var last_cell=myrow.insertCell();
	last_cell.appendChild(input);

	input=document.createElement("<input type='text'>");
	start=density.lastIndexOf("_");
	num=myParseFloat(density.substring(start+1));
	input.setAttribute("name",density.substring(0,start+1)+(num+1));
	last_cell=myrow.insertCell();
	last_cell.appendChild(input);
}
function deleteQp(item,table_id)
	{
		//
		var t=1;
		if(table_id=="table01")
		t=1;
		else
		t=2;
		var line=parseInt(item.name.split("_")[t]);
		line=line+2;
		//alert("line:"+line);
		var proc=$(table_id).rows[line];
		//alert(proc.childNodes.length+"11");
		var tb=proc.parentNode;
		//alert(tb.childNodes.length+"22");
		Element.remove(proc);
		adjustLineQp(tb,t);
	}
function adjustLineQp(tbody,t)//��ԭ4��i���滻��
	{
		var len=tbody.childNodes.length;
		//alert("len::"+len);
		var f="";
		if(t==2)
                f="fk_";
		var tag_name=f+"key_";
		var tag_v=f+"value_";
		for(var i=2;i<len;i++)
		{
			var tr_i=tbody.childNodes[i];
			var j=0;
			tr_i.childNodes[j].firstChild.name=tag_name+(i-2);
			//alert(tr_i.childNodes[j].firstChild.name);
			j++;
			tr_i.childNodes[j].firstChild.name=tag_v+(i-2);
		}
	}
function checkQieForm(form1)
{
	var i=0;
	while(typeof(form1[i])!="undefined"&&typeof(form1[i+1])!="undefined")
	{
		if(form1[i].type=="text")
		{
			if(!qiepian_update(form1[i]))
				{form1[i].focus();return false;}
		}
		i++;
		if(form1[i].type=="text")
		{
              		if(isEmpty(form1[i].value))
				{i++;continue;}
			if(!isFloat(form1[i].value))
				{form1[i].focus();alert("float:"+form1[i].value);return false;}
		}
		i++;
        }
	//alert(i);
	return true;
}
function checkDensityForm(form1)
{
	var i=0;
	//alert(form1.length);
	if(!checkChange())
		return false;
	while(typeof(form1[i])!="undefined"&&typeof(form1[i+1])!="undefined")
	{
		if(form1[i].type=="text")
		{
			if(!density_c(form1[i]))
				{form1[i].focus();return false;}
		}
		i++;
		if(form1[i].type=="text")
		{
              		if(isEmpty(form1[i].value))
				{i++;continue;}
			if(!isFloat(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"����ʵ���밴��׼�������ܶ�");return false;}
		}
		i++;
        }
	return true;
}
function checkMaoPiForm(form1)
{
	var i=0;
	if(form1[i].type=="text")
		{
			if(!isSsign(form1[i].value))
				{form1[i].focus();alert("���������������ƺ�!");return false;}
		}
        i++;
	while(typeof(form1[i])!="undefined")
	{
		if(form1[i].type=="text")
		{
			if(!isFloat(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"����ʵ���밴��׼������");return false;}
		}
		i++;
        }
	return true;
}
function checkIntForm(form1)
{

	var i=0;
	while(form1[i].type=="text"&&form1[i+1].type=="text")
		{
       		i++;
		if(form1[i].type=="text")
		{
			if(!isInteger(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"���������밴��׼������");return false;}
		}
		i++;
        	}
	return true;

}
function checkFloatForm(form1)
{

	var i=0;
	while(form1[i].type=="text"&&form1[i+1].type=="text")
		{
       		i++;
		if(form1[i].type=="text")
		{
			if(!isFloat(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"����ʵ���밴��׼������");return false;}
		}
		i++;
        	}
	return true;

}
function checkForm(form1)
{

	var i=0;
	while(form1[i].type=="text")
		{
			if(!isFloat(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"����ʵ���밴��׼������");return false;}
			i++;
        	}
	return true;

}
function checkSimForm(form1)
{
	var i=0;
	while(form1[i].type=="text")
		{
		if(form1[i].type=="text")
		{
			if(!isInteger(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"���������밴��׼������");return false;}
		}
		i++;
        	}
	return true;
}
function checkQianDaoForm(form1)
{

	var i=0;
	while(form1[i].type=="text"&&form1[i+1].type=="text"&&form1[i+2].type=="text"&&form1[i+3].type=="text")
		{
       		i++;
		if(form1[i].type=="text")
		{
			if(!isFloat(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"����ʵ���밴��׼������");return false;}
		}
		i++;
		if(form1[i].type=="text")
		{
			if(!isFloat(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"����ʵ���밴��׼������");return false;}
		}
		i+=2;
        	}
	return true;

}
var LowestSsign="ë�����͵Ĺ��";
function checkOtherForm(form1)
{
	var i=0;
	while(form1[i].type=="text")
		{
		if(form1[i].type=="text")
		{
			if(form1[i].name==LowestSsign)
			{
				if(!(isSsign(form1[i].value)))
				{
				form1[i].focus();alert(form1[i].value+"�����ƺ�,����������ë�������ƺ�");return false;
				}
				else
					{i++;continue;}
			}
			if(!isFloat(form1[i].value))
				{
				form1[i].focus();alert(form1[i].value+"����ʵ���밴��׼������");return false;
				}
		}
		i++;

        	}
	return true;
}
function checkSimilar(form1)
{
	var i=0;

		if(form1[i].type=="text")
		{
			if(!isSsign(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"�����ƺ����ͣ��밴��׼��N32����");return false;}
		}


	return true;
}

function checkSsignForm(form1)
{
	var i=0;

		for(i=0;form1[i].type!="text";i++)
		{
			if(!isSsign(form1[i].value))
				{form1[i].focus();alert(form1[i].value+"�����ƺ����ͣ��밴��׼��N32����");return false;}
		}


	return true;
}

function changexishu(o)
{
	//alert(o.propertyName);
	/*for(var i in arguments[0])
	alert(i+"::"+item[i]);*/
	if(o.propertyName!="value")
		return;
	var item=o.srcElement;
	var tr_num=item.parentNode.parentNode;

	var area=tr_num.childNodes[4].firstChild;

	var danjia=tr_num.childNodes[5].firstChild;

	var xishu=tr_num.childNodes[6].firstChild;

	var percent=tr_num.childNodes[7].firstChild;

	var fee=tr_num.childNodes[8].firstChild;

	var geshu=tr_num.childNodes[3].firstChild;

	var leixing=tr_num.childNodes[1].firstChild;
	//alert("cchange_num:"+i);i++;
      	fee.value=costtrim(myParseFloat(area.value)*myParseFloat(danjia.value)*myParseFloat(xishu.value));
	//ֻ�仯���ӹ��ɱ�Ϊֹ��
	//var pro_last=tr_num.childNodes[9].firstChld;
	//pro_last.value=costtrim((myParseFloat(fee.value)+myParseFloat(bef)/geshu)/myParseFloat(percent.value));
}
//���ӹ��ѱ仯ʱ���޸ı�����ĿǰΪֹ�ĳɱ���
function changeProCost(o)
{

	//alert("1");
	/*for(var item in o)
	alert(item+"::"+o[item]);*/
	//alert(o);
	var tr_num;
	//alert(o.type);
	if(o.type=="propertychange")
	tr_num=o.srcElement.parentNode.parentNode;
	else
	{tr_num=o;}
	var cailiao=document.getElementById("grossprice");//cailiaofee;
	var bef=0;
	//����ǵ�һ�е�
	//alert("start_pro_cost:"+num);
	//alert($(tr_num.parentNode).childElements());
	num=$(tr_num.parentNode).childElements().indexOf(tr_num)+1;
	var len=$("table3").rows.length;
	//alert("cost:"+num+"::"+len);
	if(num>len||num<=0)
	return;
	//alert("pro_cost:"+num);
	if(num==2)
	{
		bef=cailiao;
	}
	else
	{
		//alert(num);
		bef=$("table3").rows[num-2].childNodes[9].firstChild;//ǰ����һ�е�.
	}
	//alert("cost:"+tr_num.childNodes.length);
	//alert("arr:"+arguments.length);
	var area=tr_num.childNodes[4].firstChild;

	var danjia=tr_num.childNodes[5].firstChild;

	var xishu=tr_num.childNodes[6].firstChild;

	var percent=tr_num.childNodes[7].firstChild;

	var fee=tr_num.childNodes[8].firstChild;

	var geshu=tr_num.childNodes[3].firstChild;

	var leixing=tr_num.childNodes[1].firstChild;

	var pro_last=tr_num.childNodes[9].firstChild;
	//alert("pro_lst:"+pro_last.value+"::bef:"+bef.value);
	pro_last.value=costtrim((myParseFloat(fee.value)+myParseFloat(bef.value)/myParseFloat(geshu.value))/myParseFloat(percent.value));
	//changeProLast(num);

}
//���һ��.
function add()
{
	var dem_l=prompt("���뵽�ڼ��У�");
	var len=$("table3").rows.length;
	var len=len-1;
	if(dem_l>0&&dem_l<=len)
		len=dem_l-1;
	else
	return ;
	var tr_i=$("table3").rows[len];
	len=len+1;
	//alert("len:"+len);
	$(tr_i).insert({after:"<tr><td><input type='text' name='num"+len+"' value='"+len+"' size='4' style='border:0px' ondblclick='removeProcess(this)' readonly></td><td><input type='text' name='areaname"+len+"' value='' size='8'></td><td><input type='text' name='spec"+len+"' value='' size='12' ></td><td ><input type='text' name='jiagongjianshu"+len+"' value='1' size='3'></td><td ><input type='text' name='area"+len+"' value='0' size='7' ></td><td ><input type='text' name='unitprice"+len+"' value='1' size='7' ></td><td ><input type='text' name='xishu"+len+"' value='1' size='7'></td><td ><input type='text' name='percent1"+len+"' value='1' size='5' ></td><td  ><input type='text' name='unitfee"+len+"' value='0' size='9'></td><td  ><input type='text' name='processCost"+len+"' value='0' size='13'></td></tr>"});
	var tr=$($("table3").rows[len]);
    var temp=len;
	//adjustFunc(tr,temp);
	adjustLine(tr_i.parentNode);
	refreshEvent();
}
//ɾ��һ��.
function removeProcess(item)
	{


		var proc=item.parentNode.parentNode;
		//$("table3").rows[line];

		var tb=proc.parentNode;

		Element.remove(proc);

		adjustLine(tb);
	}
//����ӹ�������
function adjustLine(tbody)//��ԭ4��i���滻��
	{
		var len=tbody.childNodes.length;

		for(var i=1;i<=len-1;i++)
		{
			var tr_i=tbody.childNodes[i];
			var j=0;
			tr_i.childNodes[j].firstChild.name="num"+i;
			tr_i.childNodes[j].firstChild.value=i;

			j++;
			tr_i.childNodes[j].firstChild.name="areaname"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="spec"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="jiagongjianshu"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="area"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="unitprice"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="xishu"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="percent1"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="unitfee"+i;
			j++;
			tr_i.childNodes[j].firstChild.name="processCost"+i;
			//adjustFunc(tr_i,i);
		}
	}
function refreshEvent()
	{
	var len=$("table3").rows.length;

	for(var i=1;i<len;i++)
	{
		var tr_i=$("table3").rows[i];
		for(var j=3;j<8;j++)
		{
			var td_j=tr_i.childNodes[j];
			if(td_j.firstChild.onpropertychange)
				td_j.firstChild.detachEvent("onpropertychange",changexishu);
			td_j.firstChild.attachEvent("onpropertychange",changexishu)
		}
		if(tr_i.childNodes[8].firstChild.onpropertychange)
			tr_i.childNodes[8].firstChild.detachEvent("onpropertychange",changeProCost);
		tr_i.childNodes[8].firstChild.attachEvent("onpropertychange",changeProCost);
		if(tr_i.childNodes[9].firstChild.onpropertychange)
			tr_i.childNodes[9].firstChild.detachEvent("onpropertychange",changeProLast);
		tr_i.childNodes[9].firstChild.attachEvent("onpropertychange",changeProLast);


	}
	}


//���ӹ��ѵĵ�������Ϊֹ�ĳɱ�����仯ʱ,����һ�����¼���.

function changeProLast(o)
{
	var table3=$("table3");
	var row_len=table3.firstChild.childNodes.length-1;
	var item=o.srcElement;
	var myArr=$(item.parentNode.parentNode.parentNode).childElements();
	//alert(myArr);
	num=myArr.indexOf(item.parentNode.parentNode);
	//��������һ��,�򷵻�.
	//alert("last:"+row_len+"::"+num);
	if(num>=row_len)
		return;
        //������һ�е�ϵ��仯����.
    // alert("2");
    //alert($(myArr[num+1]).childElements());
	changeProCost(myArr[num+1]);
	//myArr[num+1].firstChild.firstChild.
}

